/*
** lagrange.c for  in /home/jousse_f//afs/rendu/math/103interpol
** 
** Made by florian jousseau
** Login   <jousse_f@epitech.net>
** 
** Started on  Tue Mar  1 17:28:12 2011 florian jousseau
** Last update Tue Mar  1 18:28:57 2011 florian jousseau
*/

#include "include/103.h"

double		algo_lagrange(t_number *nb, double x)
{
  int		i;
  int		j;
  double	d;
  double	res;

  i = 0;
  res = 0;
  while (i < 6)
    {
      j = 0;
      d = nb->y[i];
      while (j < 6)
	{
	  if (i != j)
	    d *= ((x - nb->x[j])/(nb->x[i] - nb->x[j]));
	  j += 1;
	}
      res += d;
      i += 1;
    }
  return (res);
}
